
/**
 * \file main.cpp
 * \author T. M. Jandreau
 * \date January 2, 2013
 * 
 * This file contains the binary entry point for testDDS. This test will attempt
 * to exercise the DDS middleware and the DDSEntityManager classes.
 */

#include <ace/OS.h>

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <cppunit/TestRunner.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/XmlOutputter.h>

namespace TEST {
    
    class TestDDS : public CPPUNIT_NS::TestCase {
        CPPUNIT_TEST_SUITE(TestDDS);
        CPPUNIT_TEST_SUITE_END();
        
    public:
        void setUp() {
            
        }
        
        void tearDown() {
            
        }
        
    protected:
        // this is where the actual unit tests go
    };
}

/////////////////////
CPPUNIT_TEST_SUITE_REGISTRATION(TEST::TestDDS);

int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) {
        
    // creates the event manager and controller
    CPPUNIT_NS::TestResult controller;

    // adds a listener
    CPPUNIT_NS::TestResultCollector result;
    controller.addListener(&result);

    // adds something that prints progress
    CPPUNIT_NS::BriefTestProgressListener progress;
    controller.addListener(&progress);

    // add the top suite to the test runner
    CPPUNIT_NS::TestRunner runner;
    runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
    runner.run(controller);

    CPPUNIT_NS::CompilerOutputter compilerOutputter(&result, std::cout);
    compilerOutputter.write();

    ///home/tjandreau/DEV/TestResults
    std::string testResults = "../results/TestDDS.xml";
    std::cout << " Writing output - " << testResults << std::endl;
    std::ofstream xmlFileOut(testResults.c_str());
    CPPUNIT_NS::XmlOutputter xmlOut(&result, xmlFileOut);
    xmlOut.write();

    return result.wasSuccessful() ? 0 : 1;
    
    return 0;
}
